#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>

using namespace std;

int finalPositionOfSnake(int n, vector<string>& commands) {
    int c = 0, r = 0;
    for (auto s : commands)
    {
        if (s == "UP")   c--;
        else if (s == "RIGHT")   r++;
        else if (s == "DOWN")    c++;
        else r--;
    }
    return c * n + r;
}